package com.xy.nio;

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NIOFileChannel01 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("/tmp/test.txt");
        FileChannel fileChannel = fos.getChannel();
        ByteBuffer bb = ByteBuffer.allocate(1024);
        bb.put("hello,xy".getBytes());
        bb.flip();
        fileChannel.write(bb);
        fos.close();
    }
}
